<?php

namespace app\api\server;

use app\common\library\CustomResult;
use app\common\library\Show;
use app\common\model\User;

class SocketServer extends BaseServer
{

    /**
     * Notes:给分组内的链接 广播分组的人员列表
     * @param $group //分组名称
     * @return array
     */
    public static function sendToGroup($group)
    {
        $uIds = ClientServer::getUidListByGroup($group);
        CustomResult::checkResult($uIds);
        if(!empty($uIds['data'])){
            $lists = User::where('id', 'in', $uIds['data'])->field(['id','username','nickname','avatar'])->select();
            if($lists){
                $lists = $lists->toArray();
                //发送socket通知
                return ClientServer::sendToGroup($group, 'refund_order_detail', $lists);
            }
        }
        return Show::success();
    }


    public static function sendToAdminUser($adminId, array $message)
    {
        //发送socket通知
        return ClientServer::sendToUser($adminId, "message", $message);
    }


}